<template>
  <PageCard>
    <SearchBar
      slot="top"
      :controls="searchControl"
      @search="refresh"
      v-model="searchModel"
    />
    <div v-if="$slots.default" class="mb-10"><slot /></div>
    <PaginationTable :get-list="query" v-bind="$attrs">
      <template v-slot:table="data">
        <slot name="table" v-bind="data" />
      </template>
    </PaginationTable>
  </PageCard>
</template>
<script lang="ts">
import PageCard from './index'
import SearchBar from '@/components/SearchBar/index.vue'

import PaginationTable, {
  mixin as PageMixin
} from '@/components/CommonPage/PaginationTable.vue'
/**
 * generate by vscode
 */
import { Component, Vue, Prop, Mixins } from 'vue-property-decorator'
@Component({
  name: 'PageTable',
  components: {
    PageCard,
    SearchBar,
    PaginationTable
  }
})
export default class table extends Mixins(PageMixin) {
  @Prop() searchControl?: any
  @Prop() searchFormat?: (val: any) => any

  @Prop() getList!: any

  query(params: any) {
    return this.getList(
      params,
      this.searchFormat ? this.searchFormat(this.searchModel) : this.searchModel
    )
  }
}
@Component
export class mixin extends Vue {
  list = []
  searchModel = {}
}
</script>
<style lang="scss" scoped></style>
